From 5522e20104da6afe2e4667cf45dbbbbc0e838865 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 23 Nov 2024 20:59:34 +0000 Subject: ui(mobile): Replace bottom sheet with native screens (#690) * Remove bottom sheet from bookmark info page * Remove bottom sheet from manage lists page * Remove bottom sheet from new list page * Remove bottom sheet from new bookmark page * Drop bottom-sheets * Improve the look of the modals * Make the search page fade from bottom --- .../mobile/app/dashboard/bookmarks/[slug]/info.tsx | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx (limited to 'apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx') diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx new file mode 100644 index 00000000..5d15ab6b --- /dev/null +++ b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx @@ -0,0 +1,115 @@ +import React from "react"; +import { Text, View } from "react-native"; +import { Stack, useLocalSearchParams } from "expo-router"; +import TagPill from "@/components/bookmarks/TagPill"; +import FullPageError from "@/components/FullPageError"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import FullPageSpinner from "@/components/ui/FullPageSpinner"; +import { Input } from "@/components/ui/Input"; +import { Skeleton } from "@/components/ui/Skeleton"; +import { api } from "@/lib/trpc"; + +import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; +import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils"; +import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; + +function TagList({ bookmark }: { bookmark: ZBookmark }) { + return ( + + Tags + {isBookmarkStillTagging(bookmark) ? ( + <> + + + + ) : bookmark.tags.length > 0 ? ( + + {bookmark.tags.map((t) => ( + + ))} + + ) : ( + No tags + )} + + ); +} + +function NotesEditor({ bookmark }: { bookmark: ZBookmark }) { + const { mutate, isPending } = useUpdateBookmark(); + return ( + + Notes + + + mutate({ + bookmarkId: bookmark.id, + note: ev.nativeEvent.text, + }) + } + defaultValue={bookmark.note ?? ""} + /> + + ); +} + +const ViewBookmarkPage = () => { + const { slug } = useLocalSearchParams(); + if (typeof slug !== "string") { + throw new Error("Unexpected param type"); + } + const { + data: bookmark, + isPending, + refetch, + } = api.bookmarks.getBookmark.useQuery({ bookmarkId: slug }); + + if (isPending) { + return ; + } + + if (!bookmark) { + return ( + refetch()} /> + ); + } + + let title = null; + switch (bookmark.content.type) { + case BookmarkTypes.LINK: + title = bookmark.title ?? bookmark.content.title; + break; + case BookmarkTypes.TEXT: + title = bookmark.title; + break; + case BookmarkTypes.ASSET: + title = bookmark.title ?? bookmark.content.fileName; + break; + } + return ( + + + + + + + + + + ); +}; + +export default ViewBookmarkPage; -- cgit v1.2.3-70-g09d2